#!/bin/bash
cd ~/app-root/data/temp/firefox/
curl -s http://releases.mozilla.org/pub/firefox/nightly/latest-mozilla-central/ |grep -o "[0-9]\{2\}\.0a1" |tail -1 >./candidates
if [ -s "./candidates" ]; then
if ! diff -q candidates oldnightly; then
    candidates=$(cat candidates)
    oldnightly=$(cat oldnightly)
    sed -i "s#${oldnightly}#${candidates}#g" ~/app-root/data/index/firefox.html
    #sed -i "s#${oldnightly}#${candidates}#g" ~/app-root/data/github-sh/xpi/*/do/install.rdf
    sed -i "/maxVersion/s#[0-9]\{2\}\.0a1#${candidates}#g" ~/app-root/data/list/xpi/*.rdf
    sed -i "/maxVersion/s#[0-9]\{2\}\.0a1#${candidates}#g" ~/app-root/data/xpi/rdf/*.rdf
    mv -f candidates oldnightly
    sh ~/app-root/data/github-sh/firefox/time.sh
fi
fi

#curl -s http://releases.mozilla.org/pub/firefox/nightly/latest-mozilla-aurora/ |grep -o "[0-9]\{2\}\.0a2" |tail -1 >./candidates
#if [ -s "./candidates" ]; then
#if ! diff -q candidates oldaurora; then
#    candidates=$(cat candidates)
#    oldaurora=$(cat oldaurora)
#    sed -i "s#${oldaurora}#${candidates}#g" ~/app-root/data/index/firefox.html
#    mv -f candidates oldaurora
#    sh ~/app-root/data/github-sh/firefox/time.sh
#fi
#fi
rm -f candidates*